package com.century.sjt.EMChat.db;

import android.content.ContentValues;
import android.content.Context;

import com.century.sjt.entity.MyDraft;

import java.util.List;

/**
 * Created by 炳基 on 2016/7/1.
 */
public class DraftDao {
    static final String TABLE_NAME = "new_friends_draft";
    static final String COLUMN_NAME_ID = "id";
    static final String COLUMN_NAME_FROM = "username";
    static final String COLUMN_NAME_GROUP_ID = "groupid";
    static final String COLUMN_NAME_GROUP_Name = "groupname";
    static final String COLUMN_NAME_USERID = "userid";
    static final String COLUMN_NAME_MTEXT = "mtext";
    static final String COLUMN_NAME_TIME = "time";
    static final String COLUMN_NAME_UNREAD_MSG_COUNT = "unreadMsgCount";


    public DraftDao(Context context){
    }

    /**
     * 保存Draft
     * @param Draft
     * @return  返回这条Draft在db中的id
     */
    public Integer saveDraftDao(MyDraft message){
        return DemoDBManager.getInstance().saveDraft(message);
    }

    /**
     * 更新Draft
     * @param msgId
     * @param values
     */
    public void updateDraftDao(int msgId,ContentValues values){
        DemoDBManager.getInstance().updateDraft(msgId, values);
    }

    /**
     * 获取Draft
     * @return List<MyDraft>
     */
    public List<MyDraft> getDraftDaoList(){
        return DemoDBManager.getInstance().getDraftList();
    }
    /**
     * 获取Draft
     * @return MyDraft
     */
    public MyDraft getDraftDao(String userid, String from){
        return DemoDBManager.getInstance().getDraft(userid,from);
    }
    public void deleteDraftDao(String from){
        DemoDBManager.getInstance().deleteDraft(from);
    }

    public int getUnreadDraftDaoCount(){
        return DemoDBManager.getInstance().getDraftUnreadNotifyCount();
    }

    public void saveUnreadDraftDaoCount(int count){
        DemoDBManager.getInstance().setDraftUnreadNotifyCount(count);
    }
}
